SELECT     VoucherNo, Amount, Expense, TotalAmount, Discount, NetAmount, Cash
FROM         Voucher


BEGIN TRANSACTION
GO
UPDATE    Voucher
SET              Amount = ISNULL(
                          (SELECT     SUM(Amount) AS Amount
                            FROM          VoucherDetails
                            WHERE      (VoucherID = Voucher.VoucherID) AND (AccountNo = 110003))
			 ,0)
WHERE     (VoucherNo LIKE 'PV-%') -- PR SV SR PSI PSR PS
GO
COMMIT

--------------------------

BEGIN TRANSACTION
GO
UPDATE    Voucher
SET              TotalAmount = Amount + Expense, NetAmount = Amount + Expense - Discount

WHERE     (VoucherNo LIKE 'PV-%') -- PR SV SR PSI PSR PS
GO
COMMIT

--------------------------
